package com.course.serviceImpl;

import java.util.Vector;

import com.course.bean.SolutionTo;
import com.course.daoI.SolutionDAOI;
import com.course.daoImpl.SolutionDaoImpl;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.exception.LoginException;
import com.course.serviceI.SolutionServiceI;

public class SolutionServiceImpl implements SolutionServiceI{
	
	
	
	
	boolean flag=false;

	Vector<SolutionTo> vsto=null;
	
	SolutionDAOI sdao=new SolutionDaoImpl();
	
	public Vector<SolutionTo> getQueryStatus(String login)
			throws DataNotFoundException {
		
		vsto=sdao.getQueryStatus(login);
		if (vsto.isEmpty()) {
			throw new DataNotFoundException();
			}
		      return vsto;
		      }

	public Vector<SolutionTo> getSolution(int qid, String login)
			throws DataNotFoundException {
		
		vsto=sdao.getSolution(qid, login);
		
     if (vsto.isEmpty()) {
			throw new DataNotFoundException();
			}
     return vsto;
		}

	public boolean insertSolution(SolutionTo sf) throws LoginException,
			ConnectionException {
		flag=sdao.insertSolution(sf);
		
		if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(sf.getSolution()==null ||sf.getSolution().equals("")) {
			throw new LoginException();
			}
		return flag;
		}

}
